#define _CRT_SECURE_NO_WARNINGS 1

#include <vector>

using namespace std;

class Solution {
public:
    vector<int> plusOne(vector<int>& digits) {
        int i = digits.size() - 1;
        int carry = (digits[i] + 1) / 10;
        digits[i] = (digits[i] + 1) % 10;
        for (i = digits.size() - 2; i >= 0; --i)
        {
            int tmp = digits[i];
            digits[i] = (tmp + carry) % 10;
            carry = (tmp + carry) / 10;
        }
        if (carry != 0)
        {
            digits.insert(digits.begin(), carry);
        }
        return digits;
    }
};